package modelLayer;

import java.util.ArrayList;


public class Customer extends Person {
	
private double moneySpent;
private ArrayList<SaleLinesItem> itemsBought;
private ArrayList<Sale> sales;
private double discount;

public Customer(String Id, String name, String address, String phoneNumber,
		double moneySpent,double discount) {
	super(Id, name, address, phoneNumber);
	this.moneySpent = moneySpent;
	itemsBought = new ArrayList<SaleLinesItem>();
	this.discount = discount;
	sales = new ArrayList<Sale>();
}
public ArrayList<Sale> getSales() {
	return sales;
}
public void addSale(Sale sale){
	sales.add(sale);
}
public double getMoneySpent() {
	return moneySpent;
}
public void setMoneySpent(double moneySpent) {
	this.moneySpent = moneySpent;
}
public ArrayList<SaleLinesItem> getItemsBought() {
	return itemsBought;
}
public void addItemBought(SaleLinesItem item)
{
	itemsBought.add(item);
}
@Override
public String toString() {
	return "Customer"+super.toString()+ "moneySpent=" + moneySpent + ", itemsBought="
			+ itemsBought + ", discount=" + discount + "]";
}
public String save(){
	String cust = "";
	for(SaleLinesItem c1: itemsBought){
		try{
			cust = cust + "," + c1.getID();
		}
		catch(NullPointerException npe){
			
		}
	}
	return 1+","+ super.getId()+","+super.getName()+","+super.getAddress()+","+super.getPhoneNumber()+","+moneySpent+","+discount+","+cust;
}
public double getDiscount() {
	return discount;
}
public void setDiscount(double discount) {
	this.discount = discount;
}
public void setItemsBought(ArrayList<SaleLinesItem> itemsBought) {
	this.itemsBought = itemsBought;
}
public void setSales(ArrayList<Sale> sales) {
	this.sales = sales;
}

}
